package com.JobFind.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Proxy;

import com.JobFind.DTO.LogDTO;
import com.JobFind.DTO.LogShowDTO;


/**
 * TbLog entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name="tb_log",catalog="jobfind")
@Proxy(lazy = false)
public class TbLog  implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer logId;
    private Integer userId;
    private String logIp;
    private String logTime;
    private Integer userType;

    // Constructors

    /** default constructor */
    public TbLog() {
    }

    
    /** full constructor */
    public TbLog(Integer userId, String logIp, String logTime,Integer userType) {
        this.userId = userId;
        this.logIp = logIp;
        this.logTime = logTime;
        this.setUserType(userType);
    }

   
    // Property accessors
    @Id @GeneratedValue
    
    @Column(name="LogId", unique=true, nullable=false)

    public Integer getLogId() {
        return this.logId;
    }
    
    public void setLogId(Integer logId) {
        this.logId = logId;
    }
    @Column(name="UserId", length=30)

    public Integer getUserId() {
        return this.userId;
    }
    
    public void setUserId(Integer userId) {
        this.userId = userId;
    }
    
    @Column(name="LogIp", length=30)

    public String getLogIp() {
        return this.logIp;
    }
    
    public void setLogIp(String logIp) {
        this.logIp = logIp;
    }
    
    @Column(name="LogTime", length=30)

    public String getLogTime() {
        return this.logTime;
    }
    
    public void setLogTime(String logTime) {
        this.logTime = logTime;
    }
   
    @Column(name="UserType", length=11)
    public Integer getUserType() {
		return userType;
	}


	public void setUserType(Integer userType) {
		this.userType = userType;
	}


	public LogDTO toDTO(){
    	LogDTO logDTO = new LogDTO();
    	logDTO.setLogId(this.getLogId());
    	logDTO.setLogIp(this.getLogIp());
    	logDTO.setLogTime(this.getLogTime());
    	logDTO.setUserId(this.getUserId());
    	logDTO.setUserType(this.getUserType());
    	return logDTO;
    }
	
	public LogShowDTO toShowDTO(){
		LogShowDTO logDTO = new LogShowDTO();
    	logDTO.setLogId(this.getLogId());
    	logDTO.setLogIp(this.getLogIp());
    	logDTO.setLogTime(this.getLogTime());
    	if(this.getUserType() == 2)
    		logDTO.setUserType("企业");
    	else 
    		logDTO.setUserType("个人");
    	logDTO.setUserId(this.getUserId());
    	return logDTO;
	}
}